// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "AuraWidgetController.generated.h"

class UAuraUserWidget;
class UAttributeSet;
class UAbilitySystemComponent;

USTRUCT(BlueprintType) // BlueprintType: 可作为蓝图(蓝图图表)中的变量类型类型
struct FWidgetControllerProps // 控件控制器属性 结构体,辅助类(结构体是轻量的类)用于构造 控制器
{
	GENERATED_BODY()

	FWidgetControllerProps() = default; //默认构造,即空构造

	FWidgetControllerProps(APlayerController* PC, APlayerState* PS, UAbilitySystemComponent* ASC, UAttributeSet* AS):
		PlayerController(PC), PlayerState(PS), AbilitySystemComponent(ASC), AttributeSet(AS)
	{
	} // 初始化列表,快速构造


	UPROPERTY(BlueprintReadWrite, EditAnywhere)
	TObjectPtr<APlayerController> PlayerController;

	UPROPERTY(BlueprintReadWrite, EditAnywhere)
	TObjectPtr<APlayerState> PlayerState;

	UPROPERTY(BlueprintReadWrite, EditAnywhere)
	TObjectPtr<UAbilitySystemComponent> AbilitySystemComponent;

	UPROPERTY(BlueprintReadWrite, EditAnywhere)
	TObjectPtr<UAttributeSet> AttributeSet;
};


/**
 * 控件控制器基类,控件控制器作为Controller层,要持有四大类: playerController，playerState，ASC(AbilitySystemComponent), AS(AttributeSet)
 */
UCLASS()
class AURA_API UAuraWidgetController : public UObject
{
	GENERATED_BODY()

public:
	
	// 设置控件属性
	UFUNCTION(BlueprintCallable)
	void SetWidgetControllerProps(const FWidgetControllerProps& WCProps);
	
	//发出广播的函数,初始化初始值
	virtual void BroadcastInitialValues();
	
	//绑定回调到相关依赖
	virtual void BindCallbacksToDependencies();

protected:
	
	UPROPERTY(BlueprintReadOnly, Category="WidgetController")
	TObjectPtr<APlayerController> PlayerController;

	UPROPERTY(BlueprintReadOnly, Category="WidgetController")
	TObjectPtr<APlayerState> PlayerState;

	UPROPERTY(BlueprintReadOnly, Category="WidgetController")
	TObjectPtr<UAbilitySystemComponent> AbilitySystemComponent;

	UPROPERTY(BlueprintReadOnly, Category="WidgetController")
	TObjectPtr<UAttributeSet> AttributeSet;
};
